IMPORT
IMPORT " libname " statements make function
libraries available to a program. The functions and shared constants of the function
library are imported into the program. Programs can call functions in imported
libraries as if those functions were in the same program, and programs can reference
shared constants defined in imported libraries as if those shared constants were in the
same program. External and shared variables in libraries are not visible however.
When IMPORT "libname" is compiled:
░ libname.dec is read in and compiled as if it was in the program.
░ libname.dll is loaded and linked with the program (if it exists).
░ libname.dll entry function is called (to initialize the library).
libname.dec contains statements that define types, declare functions, and define shared
constants in the function library.
libname.dec is created automatically when a program is compiled as a function library by
the program development environment (see the following EXPORT statement). For
libraries written in other languages, libname.dec must be written by the programmer or
supplier of the function libraries.
EXPORT ... END EXPORT
EXPORT and END EXPORT statements enclose type
definitions, function declarations, and shared constant definitions that programs want to
export - make visible and accessible to other programs.
When a program is compiled into a function library, the lines between EXPORT and END
EXPORT are exported to any program that imports the library with IMPORT
"libname".
blowback function - Blowback()
Programs running in the PDE are terminated when you "kill" them and when they
"crash" due to fatal errors like segment violations. Unfinished business may be
pending when programs are terminated. For example, files may have been opened and never
closed.
For programs that execute only built-in statements and intrinsics and only call functions
in the built-in libraries ( Xst , Xma , Xcm , Xgr , Xui ), all such issues are resolved
automatically by the PDE and libraries.
But the PDE and built-in libraries have no idea what happens when your program directly
calls system functions and unknown libraries. For example, if a program calls a
system function instead of the OPEN() intrinsic to open
a file, the file may still be open when the program crashes, is terminated, or finishes
without closing the file. Any subsequent attempt to open the file will therefore
fail.
To resolve this problem, whenever a program terminates, the PDE calls the Blowback()
function in the program and every library. Any program or library that calls system
functions should contain a Blowback() function to detect and resolve all "unfinished
business".